package carrier.client;

import com.example.entity.User;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;


@Component   //注意，需要将其注册为Bean，Feign才能自动注入
public class UserFallbackClient implements UserClient{
    @Override
    public User selectById(@RequestParam(required = false,name = "id") Long id){   //这里我们自行对其进行实现，并返回我们的替代方案
        System.out.println("服务降级");
        User user = new User();
        user.setUserName("我是替代方案");
        return user;
    }

    @Override
    public User registerDriver(User signUp){
        System.out.println("服务降级");
        User user = new User();
        user.setUserName("我是替代方案");
        return user;
    }

    @Override
    public List<User> selectDriver(int i,Long id){
        System.out.println("服务降级");
        List<User> list = new ArrayList<>(1);
        return list;
    }
}
